﻿using System;
using System.ComponentModel;

namespace ExFlash.Records
{
    public enum ShapeType
    {
        Shape1,
        Shape2,
        Shape3,
        Shape4
    }
    
    [TypeConverter(typeof(GradRecordConverter))]
    public class GradRecord : ISwfSerializable
    {
        public ShapeType ShapeType
        {
            get;
            private set;
        }
        
        public Byte Ratio
        {
            get;
            private set;
        }
        
        public RGBRecord Color
        {
            get;
            private set;
        }

        public GradRecord(ShapeType type)
        {
            ShapeType = type;
        }

        #region ISwfSerializable Members

        public void SwfDeserialize(BinaryBitReader reader)
        {
            Ratio = reader.ReadByte();
            
            if (ShapeType == ShapeType.Shape1 || ShapeType == ShapeType.Shape2)
            {
                Color = new RGBRecord();
            }
            else
            {
                Color = new RGBARecord(); 
            }

            Color.SwfDeserialize(reader);
        }

        public void SwfSerialize(byte[] arr, ref int offset)
        {
            throw new NotImplementedException();
        }

        #endregion
    }

    public class GradRecordConverter : ExpandableObjectConverter
    {

    }
}
